package com.dyh.quickdemo.complexExtend;

import org.junit.jupiter.api.Test;
import sun.security.util.Length;

/*
@Author=Joey Wheeler
@Date=2021/3/4 16:54
*/
public class M {

    @Test
    public void test3(){
        String s = "https://1morefun-active.oss-cn-beijing.aliyuncs.com/swatch/canvas/1589622044799_4281.png";
        String res =s.substring(s.lastIndexOf("/")+1);

        System.out.println(res);
    }


    @Test
    public void test1(){


        System.out.println(   M.class.getClassLoader().getResource("")
                .getFile());
    }


    @Test
    public void test(){
    //    System.out.println(fun("11",e->e+"!"));

        /*case 1 每个枚举都实现checker接口*/
        //System.out.println(fun("11",(CheckerEnum.LENGTH & Handler)(e->e+"!")));

        /*case 2 每个枚举的一个字段是checker*/
//        System.out.println(fun("11",(CheckerEnum1.LENGTH.checker & Handler)(e->e+"!")));

        /*case 3 LengthChecker 是一个class*/
         //System.out.println(fun("11",(LengthChecker & Handler)(e->e+"!")));

        /*case4 LengthChecker2是一个 intf */
        System.out.println(fun("122",(LengthChecker2 & Handler)(e->e+"!")));

        /*case5 LengthChecker3是一个 intf */
     //   System.out.println(fun("11",(Checker.lenthChecker3 & Handler)(e->e+"!")));




    }

    /*
    result = {Class[2]@1735}

    getClass . getInterfaces
 1 = {Class@1684} "interface com.dyh.quickdemo.complexExtend.LengthChecker2"
 0 = {Class@1682} "interface com.dyh.quickdemo.complexExtend.Handler"
    * */
    String fun(String in,Handler handler){
        if (handler instanceof Checker){
            System.out.println("调用checker");
            if (((Checker) handler).work(in,2)){
                System.out.println("checker校验通过");
                return handler.work(in);
            }
            else{
                System.out.println("checker校验不通过");
                return "";
            }
        }
        return handler.work(in);
    }



}
